using System.Collections.Generic;
using UnityEngine;

public class InfoPointForBonuseGameType : MonoBehaviour
{
	public GameObject goWithCollider;

	public GameObject ObjectForMovingPoint;

	public List<ListPointBonuseForGameType> listBonuses = new List<ListPointBonuseForGameType>();

	public TypeGame lastTypeGame;

	public void LoadingAll()
	{
		Transform[] componentsInChildren = GetComponentsInChildren<Transform>();
		List<PointForBonuse> list = new List<PointForBonuse>();
		Transform[] array = componentsInChildren;
		foreach (Transform transform in array)
		{
			if (transform.tag.Equals("Respawn"))
			{
				PointForBonuse item = default(PointForBonuse);
				item.pos = transform.transform.position;
				BonuseRespawnInfo component = transform.GetComponent<BonuseRespawnInfo>();
				item.bonuse = component.bonuse;
				item.options = component.options;
				item.timeForRespawnBonuse = component.timeForRespawnBonuse;
				item.listBonuse = new List<SpawnBonuse>();
				item.listBonuse.AddRange(component.listBonuse.ToArray());
				list.Add(item);
			}
		}
		foreach (ListPointBonuseForGameType listBonuse in listBonuses)
		{
			if (listBonuse.type == lastTypeGame)
			{
				listBonuse.listSpawnBonuse.Clear();
				listBonuse.listSpawnBonuse.AddRange(list);
			}
		}
		Transform[] array2 = componentsInChildren;
		foreach (Transform transform2 in array2)
		{
			if (transform2.tag.Equals("Respawn"))
			{
				Object.DestroyImmediate(transform2.gameObject);
			}
		}
	}

	public void PutAllPoint(List<PointForBonuse> listBonuse)
	{
		foreach (PointForBonuse item in listBonuse)
		{
			GameObject gameObject = Object.Instantiate(ObjectForMovingPoint);
			gameObject.SetActive(true);
			gameObject.transform.position = item.pos;
			gameObject.transform.parent = base.transform;
			BonuseRespawnInfo component = gameObject.GetComponent<BonuseRespawnInfo>();
			component.options = item.options;
			component.timeForRespawnBonuse = item.timeForRespawnBonuse;
			component.listBonuse = item.listBonuse;
			component.bonuse = item.bonuse;
			foreach (SpawnBonuse item2 in component.listBonuse)
			{
				gameObject.gameObject.name += item2.spawnType;
			}
		}
	}
}
